





----------------------------------
----------------------------------
----------   分辨率  --------------
----------------------------------

fenBianLv = {}

fenBianLv.devX = 1080;
fenBianLv.devY = 1920;

--运行信息
fenBianLv.runX, fenBianLv.runY = getScreenSize()
-- 倍率
fenBianLv.rotX = fenBianLv.runX /  fenBianLv.devX;
fenBianLv.rotY = fenBianLv.runY /  fenBianLv.devY;

function fenBianLv.devToRun_x(num)
    return  math.ceil(fenBianLv.rotX * num)
end

function fenBianLv.devToRun_y(num)
    return math.ceil(fenBianLv.rotY * num)
end

function fenBianLv.runToDev_x(num)
    return math.ceil(num / fenBianLv.rotX )
end

function fenBianLv.runToDev_Y(num)
    return math.ceil(num / fenBianLv.rotY )
end




-- 手指移动
--[[
function szMove(x, y,eX,eY)
  touchDown(1,x, y)
  mSleep(30)
  touchMove(1,eX,eY)
  mSleep(30)
  touchUp(1, eX,eY)  
end
--]]
function szDaxiao()
    return fenBianLv.devToRun_x(100)
end



-- 点击命令
function click(x, y)
    sysLogFmt("点击位置  x:%s y:%s", x, y)
    local hudId = createHUD()
    showHUD(hudId, "", 1, "0xffff0000", "shouzhi.png", 0, x, y, szDaxiao(), szDaxiao())      --显示HUD内容
    touchDown(2, x, y);
    mSleep(50);
    touchUp(2, x, y);
    mSleep(600);
    hideHUD(hudId)

end

function click1()
    click(500, 500);
end

function click_kong()
    -- click(    1068,420)
end




-- 手指移动
function szMove(x, y, eX, eY)
    local hudId = createHUD()
    showHUD(hudId, "", 1, "0xffff0000", "shouzhi.png", 0, x, y, szDaxiao(), szDaxiao())      --显示HUD内容
    touchDown(1, x, y)

    local diffX = x - eX;
    local diffY = y - eY;

    local tempX = x;
    local tempY = y;

    local step = 50;

    local index = 0
    while not (tempX == eX) or not (tempY == eY) do

        index = index + 1;
        -- x
        if diffX > 0 then
            tempX = tempX - step
            if tempX < eX then
                tempX = eX
            end
        else
            tempX = tempX + step
            if tempX > eX then
                tempX = eX
            end
        end

        -- y
        if diffY > 0 then
            tempY = tempY - step
            if tempY < eY then
                tempY = eY
            end
        else
            tempY = tempY + step
            if tempY > eY then
                tempY = eY
            end
        end
        --toast(tostring(tempX)..","..tostring(tempY))
        showHUD(hudId, "", 1, "0xffff0000", "shouzhi.png", 0, tempX, tempY, szDaxiao(), szDaxiao())
        mSleep(50)
        touchMove(1, tempX, tempY)
    end
    showHUD(hudId, "", 1, "0xffff0000", "shouzhi.png", 0,eX, eY, szDaxiao(), szDaxiao())      --显示HUD内容
    mSleep(200)
    touchUp(1, eX, eY)

    hideHUD(hudId)
end

-- 到int
function toInt(num)
    return math.ceil(num)
end 

